package com.bmf.module.rbac.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bmf.core.result.PageResponse;
import com.bmf.module.rbac.entity.RbacUser;
import com.bmf.module.rbac.service.RbacUserService;
import com.bmf.module.rbac.vo.*;
import com.bmf.module.testQuestions.vo.QuestionPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import com.bmf.core.result.R;

/**
 * (RbacUser)表控制层
 *
 * @author makejava
 * @since 2022-12-27 15:33:18
 */
@RestController
@RequestMapping("rbacUser")
@Api(tags = {"用户接口"})
public class RbacUserController{

    /**
     * 服务对象
     */
    @Resource
    private RbacUserService rbacUserService;

    @PostMapping("/login")
    @ApiOperation(value = "登录")
    public R login(@RequestBody RbacUser user){
        return rbacUserService.login(user);
    }

    @PostMapping("/logout")
    @ApiOperation(value = "退出登录")
    public R logout(){
        return rbacUserService.logout();
    }

    @PostMapping("/insert")
    @ApiOperation(value = "添加")
    public R<Integer> insert(@RequestBody @Validated RbacUserCreateVo rbacUserCreateVo){
        return R.success(rbacUserService.insert(rbacUserCreateVo));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    public R<Void> delete(@RequestBody List<Integer> ids){
        rbacUserService.delete(ids);
        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public R update(@RequestBody RbacUserUpdateVo rbacUserUpdateVo){
        rbacUserService.update(rbacUserUpdateVo);
        return R.ok();
    }

    @PostMapping("/select/{id}")
    @ApiOperation(value = "查询")
    public R<RbacUserResultVo> select(@PathVariable("id") Integer id){
        return R.success(rbacUserService.select(id));
    }

    @PostMapping("/selectAll")
    @ApiOperation(value = "查询所有用户")
    public R<PageResponse<RbacUserResultVo>> selectAll(@RequestBody RbacUserPageVo rbacUserPageVo) {
        return R.success(rbacUserService.selectAll(rbacUserPageVo));
    }

}

